public class Solution {
    public boolean isPalindrome(String s) {
        // 将输入字符串转为小写，并移除非字母数字字符
        StringBuilder filteredString = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (Character.isLetterOrDigit(c)) {
                filteredString.append(Character.toLowerCase(c));
            }
        }

        // 使用双指针从前后开始检查是否为回文
        int left = 0;
        int right = filteredString.length() - 1;

        while (left < right) {
            if (filteredString.charAt(left) != filteredString.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }

        return true;
    }
}
